package cn.com.java.config;

import cn.com.java.core.HttpRes;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author liushuntao
 * @date 2024/1/4
 */
@ControllerAdvice
public class GlobalExceptionConfig {

    /**
     * 系统异常处理
     *
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public HttpRes error(Exception e) {
        e.printStackTrace();
        return HttpRes.ERROR(e.getMessage(),null);
    }
}
